﻿using hyjx.bind;
using GanFengLogViewer.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GanFengLogViewer.Commands
{
    public class PrePageCommand : CommandBase
    {
        public override bool CanExecute(object? parameter)
        {
            MainWindowViewModel? vm = (MainWindowViewModel?)parameter;
            if (vm == null)
                return false;

            if(!vm.IsIdle) 
                return false;

            return vm.Pagor.CurrentPageNumber > 1;
        }

        public override void Execute(object? parameter)
        {
            if (!CanExecute(parameter))
                return;

            MainWindowViewModel? vm = (MainWindowViewModel?)parameter;
            if (vm == null)
                return;

            vm.Pagor.CurrentPageNumber -= 1;
            vm.GetLogs();
        }
    }
}
